package com.atguigu.java3;

//封装与隐藏练习，PPT95，练习8
public class Person{

		public static void main(String[] args) {
				PersonTest b = new PersonTest();
				
				b.setAge(70);
				int age = b.getAge();
				System.out.println("age = " + age);
				
				b.setAge(135);
				age = b.getAge();
				System.out.println("age = " + age);
		}
}

class PersonTest{
		private int age;
		
		public void setAge(int i){
				if(i >=0 && i <= 130){
						age = i;
				}else{
						System.out.println("Error! Please input the age in 0~130!");
				}
		}
		
		public int getAge(){
				return age;
		}
	
}

